package com.neusoft.common;


import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import com.neusoft.common.util.util;

/**
 * 
 * Created By YZ at Jun 30, 2010 11:00:26 AM
 * Class:Const
 *
 */
public class Const{
	 /**
     * session user_info name
     */
    public static final String SESSION_VISTOR_ACCESS = "permissions";
    public static final String SESSION_TASK_INFO="task_manager";
    public static final String SESSION_USER_INFO="user_manager";
    public static final String RESOURCES_FU_MAP="resourceFUMap";
    public static final String RESOURCES_U_MAP="resourceUMap";
    public static final String ZERO = "0";
    public static final String ONE = "1";
    public static final String TWO = "2";
    public static final String THREE = "3";
    public static final String FOUR = "4";
    public static final String FIVE = "5";
    public static final String SIX = "6";
    public static final String SEVEN = "7";
    //－－－－－－－－－－－－－－－状态对应映射 start－－－－－－－－－－－－－－－－－－－－－－
    /**
     * 停用,否
     */
    public static final String DISABLE = "0";
    /**
     * 启用，是
     */
    public static final String ENABLED = "1";

    /**
     * 是否对应map关系
     */
    public static Map<String, String> YesOrNo(){
        Map<String, String> map = new LinkedHashMap<String, String>();
        map.put(DISABLE, "<font color='red'>是</font>");
        map.put(ENABLED, "否");
        return map;
    }

    /**
     * 获取是否的select选项
     *
     * @param selectName
     * @param selectID
     * @param selectedValue
     * @param isFull
     * @param jsString
     *
     * @return
     */
    public static String YesOrNoSelect(String selectName,
            String selectID,
            String selectedValue,
            boolean isFull,
            String jsString){
        return util.selectGenerator(YesOrNo(), selectName, selectID, selectedValue, isFull, "", jsString);
    }

    /**
     * 启用停用对应map关系
     */
    public static Map<String, String> disableAndEnabledMap(){
        Map<String, String> map = new LinkedHashMap<String, String>();
        map.put(DISABLE, "<font color='red'>停用</font>");
        map.put(ENABLED, "启用");
        return map;
    }
    /**
     * 获取启用，停用状态的select选项
     *
     * @param selectName    select的name
     * @param selectedValue 被选中值
     * @param isFull        是否包含不限选项
     *
     * @return
     */
    public static String disableOrEnabledSelect(String selectName, String selectID, String selectedValue,boolean isFull){
        return util.selectGenerator(disableAndEnabledMap(), selectName, selectID, selectedValue, isFull, "", "");
    }
    /**
     * 成功失败map
     * @return
     */
    public static Map<String, String> successOrNoMap(){
    	Map<String, String> map = new HashMap<String, String>();
    	map.put(DISABLE, "<font color='red'>失败</font>");
        map.put(ENABLED, "成功");
        return map;
    }
    public static String successOrNoSelect(String selectName, String selectID, String selectedValue, boolean isFull){
    	return util.selectGenerator(successOrNoMap(), selectName, selectID, selectedValue, isFull, "", "");
    }
    /**
     * 性别map
     *
     * @return
     */
    public static Map<String, String> sexMap(){
        Map<String, String> map = new LinkedHashMap<String, String>();
        map.put("1", "男");
        map.put("2", "女");
        return map;
    }

    /**
     * 生成性别的radio
     *
     * @param radioName
     * @param checkedValue
     * @param jsString
     *
     * @return
     */
    public static String sexRadio(String radioName, String radioId, String checkedValue, String jsString){
        return util.radioGenerator(sexMap(), radioName, radioId, checkedValue, jsString);
    }




    //-----------------------------end--------------------------------------

    /**
     * 12个月份的map
     */
    public static Map<String, String> monthMap(){
        Map<String, String> map = new LinkedHashMap<String, String>();
        for(int i = 1; i < 13; i++){
            String month = String.valueOf(i);
            map.put(month, month);
        }
        return map;
    }
    

    /**
     * 排序map
     *
     * @return
     */
    public static Map<String, String> orderMap(){
        Map<String, String> orderMap = new HashMap<String, String>();
        orderMap.put(Const.ZERO, "");
        orderMap.put(Const.ONE, "");
        orderMap.put(Const.TWO, " desc");
        return orderMap;
    }


    /**
     * 公司规模map
     * @return
     */
    public static Map<String, String> scale_Map(){
        Map<String, String> map = new LinkedHashMap<String, String>();
        map.put("0", "10人以下");
        map.put("1", "10-50人");
        map.put("2", "50-100人");
        map.put("3", "100-150人");
        map.put("4", "150-500人");
        map.put("5", "500人以上");
        return map;
    }
    
    /**
     * 所属行业
     */
    public static Map<String,String> industryMap(){
    	 Map<String, String> map = new LinkedHashMap<String, String>();
         map.put("0", "制造业");
         map.put("1", "服务业");
         map.put("2", "零售业");
         map.put("3", "批发业");
         return map;
    }
    
    
    public static Map<String, String> sysFunctionMap(){
		Map<String, String> sysFunctionMap=new HashMap<String, String>();
		sysFunctionMap.put("0", "采购管理");
		sysFunctionMap.put("1", "记账管理");
		sysFunctionMap.put("2", "成本核算");
		sysFunctionMap.put("3", "存货管理");
		sysFunctionMap.put("4", "市场营销");
		sysFunctionMap.put("5", "企业计划");
		sysFunctionMap.put("6", "人与生产力");
		return sysFunctionMap;
    }
    
    
    /**
     * 输出脚本
     *
     * @param str
     */
    public static void printScript(HttpServletResponse response, String str){
        response.setContentType("text/html;charset='utf-8'");
        response.setCharacterEncoding("utf-8");
        response.setHeader("charset", "utf-8");
        PrintWriter pw = null;
        try{
            pw = response.getWriter();
            pw.print(str);
            pw.flush();
        } catch(IOException e){
            e.printStackTrace();
        } finally{
            pw.close();
        }
    }
}
